package com.example.noelwhereismystuffs.presenters;

import android.util.Log;

import com.example.noelwhereismystuffs.models.IAdminProfileModel;
import com.example.noelwhereismystuffs.views.AdminProfileUIActivity.IAdminProfileUIView;

public class AdminProfilePresenter {
	private IAdminProfileModel myModel;
	private IAdminProfileUIView myView;
	private static final String ADD = "Add";
	private static final String REMOVE = "Remove";
	private static final String USER = "User";
	private static final String ADMIN = "Admin";
	private static final String LOCK = "Lock";
	private static final String UNLOCK = "Unlock";
	
	public AdminProfilePresenter(IAdminProfileModel model, IAdminProfileUIView view){
		myModel = model;
		myView = view;
	}
	
	/**
	 * Tell the model to do tasks 
	 * 
	 * @param userType
	 * @param actionType
	 * @param username
	 * @param email
	 * @param password
	 */
	public void onExecuteClick(String userType, String actionType, String username, String email, String password){
		if (userType.equals(USER)) {
			Log.d("AdminProfilePresenter", "AdminProfilePresenter " + userType);
			executeOnUser(actionType, username, email, password);
		}
		else {
			Log.d("AdminProfilePresenter", "AdminProfilePresenter " + userType);
			executeOnAdmin(actionType, username, email, password);
		}
	}
	
	/**
	 * Do tasks on User
	 * 
	 * @param actionType
	 * @param username
	 * @param email
	 * @param password
	 * @return
	 */
	private String executeOnUser(String actionType, String username, String email, String password){
		String res = "";
//		if (actionType.equals(ADD)){
//			myModel.addUser(username, email, password);
//			res = ADD + ADMIN;
//			Log.d("AdminProfilePresenter", "Adding new user");
//		}else if (actionType.equals(LOCK)){
//			myModel.lockUser(email);
//			Log.d("AdminProfilePresenter", "Locking user");
//		}else if (actionType.equals(UNLOCK)){
//			myModel.unlockUser(email);
//			Log.d("AdminProfilePresenter", "Unlocking user");
//		}else if (actionType.equals(REMOVE)){
//			myModel.removeUser(email);
//			Log.d("AdminProfilePresenter", "Removing user");
//		}
		Log.d("AdminProfilePresenter", "Finished executeOnUser tasks");
		myView.advance();
		return res;
	}
	
	/**
	 * Do tasks on Admin
	 * @param actionType
	 * @param username
	 * @param email
	 * @param password
	 * @return
	 */
	private String executeOnAdmin(String actionType, String username, String email, String password){
		String res = "";
//		if (actionType.equals(ADD)){
//			myModel.addAdmin(username, email, password);
//			res = ADD + ADMIN;
//			Log.d("AdminProfilePresenter", "Adding new addmin");
//		}else if (actionType.equals(LOCK)){
//			myModel.lockUser(email);
//			Log.d("AdminProfilePresenter", "Locking addmin");
//		}else if (actionType.equals(UNLOCK)){
//			myModel.unlockUser(email);
//			Log.d("AdminProfilePresenter", "Unlocking addmin");
//		}else if (actionType.equals(REMOVE)){
//			myModel.removeUser(email);
//			Log.d("AdminProfilePresenter", "Removing addmin");
//		}
//		Log.d("AdminProfilePresenter", "Finished executeOnAdmin tasks");
//		myView.advance();
		return res;
	}
}
